﻿@using HP.HPTRIM.Service;
@using HP.HPTRIM.ServiceModel;
<!doctype html>
@using HP.HPTRIM.WebDrawer;
@using ServiceStack.ServiceInterface;
@functions {

    public bool showLogout()
    {
        return this.Request.Cookies.ContainsKey("FedAuth");
    }

    public bool hideMenu()
    {
        return ViewBag.HideMenu ?? false;
    }
    
	public string menuClass(string query) {
		string q = @HttpContext.Current.Request.QueryString["q"];

		string[] qItems = new string[] { "recInTray", "recDueTray" };

		string[] searchPages = new string[] {"searchclausehelp", "index" };
		
		if (q == query) {
			return "menu-active ";	
		}

		if (HttpContext.Current.Request.Path.ToLower().Split(new char[]{'/'}).Last() == query
			&& !qItems.Contains(q)
			)
		{
			return "menu-active ";
		}
		
		if (query == "help"
			&& searchPages.Contains(HttpContext.Current.Request.Path.ToLower().Split(new char[]{'/'}).Last())) {
				return "menu-active ";
		}

		return null;
	}


	public string GetTitle()
	{
		string title = ViewBag.Title;
		if (title == null)
		{
			if (HttpContext.Current.Request.QueryString["q"] != null)
			{
				title = Translations.lang.search_results;

			}
			else if (this.Model.Results != null && this.Model.Results.Count == 1)
			{
				title = this.Model.Results[0].NameString;
			}
			else
			{
				title = Translations.lang.record_search;
			}
		}

		return string.Format(Translations.lang.webdrawer, title);
	}

}

<html>
<head>

    <meta charset="UTF-8">
	@if (this.Request.UserAgent.ToLower().Contains("iphone")) {
	 <meta name="viewport" content="width=420" />
 } else {
	<meta name="viewport" content="width=device-width, maximum-scale=1.0" />
 }	
    
	<meta http-equiv="X-UA-Compatible" content="IE=edge" >
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="format-detection" content="telephone=no">
	<title>@GetTitle()</title>
	<link href="~/scripts/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
	<link href="~/css/webdrawer.css" type="text/css" rel="stylesheet"/>

	
	@("<!--[if lt IE 9]>".AsRaw())
	<link rel="stylesheet" type="text/css" href="~/css/webdrawer_ie8.css" />
	@("<![endif]-->".AsRaw())

    <link rel="shortcut icon" href="@Url.Content("~/images/favIcon.ico")" />

    <meta name="google" content="notranslate" />

    @RenderSection("customhead")
</head>
<body class="@(hideMenu() ? "no-image" : null)">
    <div id="maincontainer">
        <div id="topsection">
            <div class="blue-line">&nbsp;</div>
            <div class="innertube">
                <img id="banner-img-large" src="~/images/top-banner-logo.png" />
                <img id="banner-img-small" src="~/images/top-banner-logo-title-SM.png" />
            </div>
            @if (showLogout())
            {
                <div class="dropdown pull-right" style="margin: -45px 10px 0 0;">
                    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">@this.TrimHelper.CurrentUser.FormattedName <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                        <li>
                            <a href="~/auth/adlogout">Logout</a>
                        </li>
                        <li>
                            <a href="~/Location/Me">Profile</a>
                        </li>
                    </ul>
                </div>
            }
        </div>
        <div id="contentwrapper" class="@(hideMenu() ? "no-menu" : null)">

            <div id="contentcolumn" class="@(hideMenu() ? "no-menu" : null)">@RenderBody()</div>
        </div>
    </div>
    @if (!hideMenu())
    {
        <div id="leftcolumn">
            <ul class="nav nav-list left-menu">

                @foreach (var trimType in new[]{
						new {Caption = Translations.lang.menu_search, query="_form", image="Search_blue_16.png"},
                        new {Caption = Translations.lang.menu_in_tray , query="recInTray", image="intray_blue_16.png"},
                        new {Caption = Translations.lang.menu_due_tray ,  query="recDueTray", image="duetray_blue_16.png"}
                    })
                    {
                        if (string.IsNullOrEmpty(trimType.query)) {
                    <li>
                        <a class="@menuClass("record")" href="~/Record">
                            <span>@trimType.Caption<img src="~/images/@trimType.image" alt="@trimType.Caption" /></span>
                        </a>

                    </li>

                        } else if (trimType.query == "_form") {
                    <li>
                        <a class="@menuClass("formsearch")" href="~/FormSearch">
                            <span>@trimType.Caption<img src="~/images/@trimType.image" alt="@trimType.Caption" /></span>
                        </a>

                    </li>

					} else {
                    <li>
                        <a class="@menuClass(trimType.query)loc-switch" href="~/Record?q=@trimType.query">
                            <span>@trimType.Caption<img src="~/images/@trimType.image" alt="@trimType.Caption" /></span>
                        </a>
                    </li>
                    }
                }
                <li>
                    <a class="@menuClass("help")" href="~/help/index">
                        <span>@Translations.lang.menu_help<img src="~/images/help_blue_16.png" alt="@Translations.lang.menu_help" /></span>
                    </a>
                </li>

            </ul>
            <div id="quick-search-forms">
                <form class="form-horizontal location-search" action="~/DocuSignLogout" method="POST">
                    <button class="btn nowrap search-btn" type="submit">DocuSign Logout</button>
                </form>
                <form class="form-horizontal location-search" action="~/Record" method="GET">
                    <input type="text" name="q" autocomplete="off" />
                    <button class="btn nowrap search-btn" type="submit">@Translations.lang.quick_search</button>
                </form>
                <hr />
                <form class="form-horizontal location-search" action="~/Location" method="GET">
                    <input type="text" name="q" autocomplete="off" />
                    <button class="btn nowrap search-btn" type="submit">@Translations.lang.location_search</button>
                </form>
            </div>
        </div>
        
    }
        <div id="bottom-blue-line" class="blue-line"></div>

        <script src="~/scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
        <script src="~/scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="~/Views/WDSearchClauseDefJS?trimType=Record" type="text/javascript"></script>
        <script src="~/EnumItemJS?Enums=SearchClauseGroup" type="text/javascript"></script>
        <script src="~/scripts/webdrawer.js" type="text/javascript"></script>


        @RenderSection("scripts")
    </body>
</html>

